<%layout("/admin/common/default.html",{'title' : '菜单管理'}){%>
<script type="text/javascript">
        // 删除
        function deleteCategory(ids) {
            if (confirm('您确定要删除吗？') == true) {
                $.ajax({
                    method: "post",
                    url: '${base}/systemMenu/delete',
                    data: "id=" + ids + "",
                    dataType: "json",
                    async: false,
                    success: function (data) {
                        if (data.status == "success") {
                            alert(data.message);
                            location.href = '${base}/systemMenu/list';
                        } else if (data.status == "error") {
                            alert(data.message);
                        }
                    }
                });
            }
        }

</script>
<script type="text/javascript">
    $().ready(function () {
        // 树折叠
        $(".categoryName").click(function () {
            var level = $(this).parent().attr("level");
            var isHide;
            $(this).parent().nextAll("tr").each(function () {
                var thisLevel = $(this).attr("level");
                if (thisLevel <= level) {
                    return false;
                }
                if (isHide == null) {
                    if ($(this).is(":hidden")) {
                        isHide = true;
                    } else {
                        isHide = false;
                    }
                }
                if (isHide) {
                    $(this).show();
                } else {
                    $(this).hide();
                }
            });
            resetHeight();
        });
    })
    function resetHeight() {
        ifm = $("#mainFrame");
        ifmHeight=$(".admin-content").height();
        ifm.height(ifmHeight);
    }

</script>
<style type="text/css">
    <!--
    .am-icon-folder-o {
        cursor: pointer;
    }
    -->
</style>
<body>
<!--在这里编写你的代码-->
<div class="admin-content">
    <div class="am-cf am-padding" style="padding:1rem 1.6rem 1.6rem 1rem;margin:0px;">
        <!--  padding:1px 2px 3px 4px;上、右、下,和左   -->
        <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">系统菜单</strong> /
            <small>菜单列表</small>
        </div>
    </div>
    <form class="am-form" id="listForm" action="${base}/brand/list" method="post">
        <div class="am-g">
            <div class="am-u-sm-12 am-u-md-6" style="padding:0px 1.6rem 1.6rem 1rem;margin:0px;">
                <div class="am-btn-toolbar">
                    <div class="am-btn-group am-btn-group-xs">
                        <button type="button" class="am-btn am-btn-default"
                                onclick="location.href='${base}/systemMenu/add'"><span class="am-icon-plus"></span> 新增
                        </button>
                    </div>
                </div>
            </div>
        </div>
        <div class="am-g">
            <div class="am-u-sm-12" style="padding:0px 5px 0px 0px;margin:0px;">
                <!--  padding:1px 2px 3px 4px;上、右、下,和左   -->
                <table class="am-table am-table-striped am-table-hover table-main" style="padding:0px;margin:0px;">
                    <thead>
                    <tr>
                        <th class="table-title">分类名称</th>
                        <th>排序</th>
                        <th class="table-set">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <%for(item in menuTreeList){%>
                    <tr level="${item.level!}"
                    <%if (item.level != 0){%>style="display: none;"<%}%> >
                    <td class="categoryName">
				    <span style="margin-left: ${item.level * 20}px;">
					<%if (item.level == 0){%>
						<i class="am-icon-folder-o"></i>
					<%}else{%>
						<i class="am-icon-folder-open-o"></i>
					<%}%>
					${item.name}
				    </span>
                    </td>
                    <td>${item.orderList}</td>
                    <td>
                        <div class="am-btn-toolbar">
                            <div class="am-btn-group am-btn-group-xs">
                                <%if (item.children.~size > 0){%>
                                <button type="button"
                                        class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only"
                                        disabled="disabled"><span class="am-icon-trash-o"></span> 删除
                                </button>
                                <%}else{%>
                                <button id="deleteAction" type="button"
                                        class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only"
                                        onclick="deleteCategory('${item.id}')"><span class="am-icon-trash-o"></span>
                                    删除
                                </button>
                                <%}%>
                                <button type="button" class="am-btn am-btn-default am-btn-xs am-text-secondary"
                                        onclick="location.href='${base}/systemMenu/edit?id=${item.id}'" title="编辑"><span
                                        class="am-icon-pencil-square-o"></span>编辑
                                </button>
                            </div>
                        </div>
                    </td>
                    </tr>
                    <%}%>
                    </tbody>
                </table>
                <div class="am-cf">
                    <!-- 分页 -->
                    <%if (menuTreeList.~size == 0){%>
                    <div class="am-kai">
                        <h3>没有找到任何记录!</h3>
                    </div>
                    <%}%>
                </div>
            </div>
        </div>
    </form>
</div>
</body>

<%}%>